package com.commpany.servie.basic.promotion.business.read.promotion.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.commpany.jdq.core.orm.Pagination;
import com.commpany.servie.basic.promotion.business.read.promotion.PromotionReadManage;
import com.commpany.servie.basic.promotion.dao.read.PromotionReadDAO;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import com.commpany.jdq.core.common.PageResult;
import com.commpany.servie.basic.promotion.po.PromotionPO;
@Slf4j
@Service
public class PromotionReadManageImpl implements PromotionReadManage {
	@Autowired
	private PromotionReadDAO promotionReadDAO;
	
	@Override
    public PromotionPO getPromotionService(PromotionPO po){

         return  promotionReadDAO.findById(po);
    }
    @Override
	public PageResult<PromotionPO> selectPromotionPageService(PromotionPO po, Pagination page){

	    page.setLimitStart((page.getPageNo() - 1) * page.getPageSize());
		PageResult<PromotionPO> result = new PageResult<PromotionPO>();
		List<PromotionPO> list = promotionReadDAO.findOfPage(po, page);
		int count = promotionReadDAO.countOfPage(po);
		result.setList(list);
		result.setTotalSize(count);
		result.copy(page);
		return result;
		
	}
	
    @Override
	public int countPromotionService( PromotionPO po ){

	    return promotionReadDAO.countOfPage(po);
	
	}
	
    @Override
	public List<PromotionPO> queryPromotionService(PromotionPO po){

	   return  promotionReadDAO.findAll(po);
	}
	
}
	